package com.rmb.api.controller;

import com.rmb.api.entity.Droposer;
import com.rmb.api.service.DroposerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @author zhao
 */
@RestController
@RequestMapping("/Droposer")
public class DroposerController {
    @Autowired
    private DroposerService droposerService;

    @GetMapping("findList")
    public List<Droposer> findList(){
        return droposerService.findAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @GetMapping("/findBy/{id}")
    public Droposer findById(@PathVariable("id") Long id){
      return this.droposerService.findById(id);
    }

    /**
     *添加
     * @return
     ***/
    @PostMapping("/add")
    public int add(@RequestBody Droposer droposer){
        int insert = droposerService.insert(droposer);
        return insert;
    }

    /**
     *
     * 修改
     *@return
     * **/
    @PutMapping("/update")
    public int update(@RequestBody Droposer droposer){
        int update = droposerService.update(droposer);
        return update;
    }
    /**
     *根据id查询
     * @return
     ***/
    @DeleteMapping("/del/{id}")
    public int del(@PathVariable("id") Long id){
        int i = droposerService.deleteById(id);
        return i;
    }

}
